package view.tables;

import java.awt.Component;

import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

@SuppressWarnings("serial")
public class TableComboBox extends JComboBox implements TableCellRenderer {

	public TableComboBox(Object[] items) {
		super(items);
	}
	
	public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
        if (isSelected) {
            setForeground(table.getSelectionForeground());
            super.setBackground(table.getSelectionBackground());
        } else {
            setForeground(table.getForeground());
            setBackground(table.getBackground());
        }

        int modelRow = table.convertRowIndexToModel(row);
        setSelectedItem(table.getModel().getValueAt(modelRow, column));
        setRenderer(new IconizedListRenderer());
        return this;
    }
	

}
